package com.supergdtop.www.run.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.widget.DrawerLayout;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.asum.xtoolbar.utils.XTopBar;
import com.supergdtop.www.run.R;
import com.supergdtop.www.run.activity.designer.MainActivityDesigner;
import com.supergdtop.www.run.tools.DbOpenhelper;
import com.supergdtop.www.run.tools.XLog;

public class MainActivity extends BaseActivity {


    private MainActivityDesigner uiDesigner;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        uiDesigner = (MainActivityDesigner) designer.design(this, R.layout.activity_main);
        uiinitilize();
        clicklistener();
    }

    private void clicklistener() {

        //——————用户登陆信息获取——————————//
        uiDesigner.loginbutton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            EditText usename = uiDesigner.userinput;
            String uservalue = usename.getText().toString();
            XLog.i(uservalue);

            EditText pwdtext = uiDesigner.pwdinput;
            String pwdvlue = pwdtext.getText().toString();
            XLog.i(pwdvlue);

            Toast.makeText(getApplicationContext(), "用户名："+usename.getText()+"密码："+pwdtext.getText(),Toast.LENGTH_LONG).show();
        }
    });
        //——————新用户注册跳转——————————//
        uiDesigner.registerbutton.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                final Intent intent=new Intent();
                intent.setClass(MainActivity.this, RegisterActivity.class);//方法2
                startActivity(intent);
            }
        });
    }

    private void uiinitilize() {
        uiDesigner.drawerLayout.setDrawerListener(new DrawerLayout.DrawerListener() {
            public void onDrawerSlide(View drawerView, float slideOffset) {
            }
            public void onDrawerOpened(View drawerView) {
                drawerView.setClickable(true);
            }
            public void onDrawerClosed(View drawerView) {

            }
            public void onDrawerStateChanged(int newState) {
            }
        });
    }

    public int check(String username,String pwdtext)
    {
            return 1;
    }
}
